home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n09.arc / POPREPT.PRG < prev    next >
Text File  |  1991-04-16  |  3KB  |  100 lines

  1.  
  2. **************************************************************
  3. *   Program:  POPREPT.PRG
  4. *    System:  Example, Dynamic Definition of Report Groupings
  5. *
  6. *
  7. *  Function:  Reptgroup()
  8. * Rept Form:  Salesrpt.FRX
  9. *      Data:  SALES.DBF (struct & index keys below)
  10. **************************************************************
  11.  
  12. * Structure for database: H:\SALES.DBF
  13. * Number of data records:      11
  14. * Date of last update   : 12/10/90
  15. * Field  Field Name  Type       Width    Dec
  16. *     1  ORDER_NO    Character      8
  17. *     2  DIVISION    Character     10
  18. *     3  REGION      Character      2
  19. *     4  ORDER_DATE  Date           8
  20. *     5  QUANTITY    Numeric       10
  21. *     6  PRODUCT     Character     10
  22. * ** Total **                      49
  23.  
  24. CLEAR ALL
  25. CLOSE ALL
  26. SET SAFETY OFF
  27. SET TALK OFF
  28.  
  29. * Open the database and associated index files, ordinarily:
  30. * USE sales INDEX svolume, sregion, sdivisn, sproduct
  31.  
  32. * In this example we'll create the index files now:
  33.  
  34. USE sales
  35. INDEX ON STR(quantity,10,0)+DTOS(order_date) TO svolume
  36. INDEX ON region+DTOS(order_date) TO sregion
  37. INDEX ON division TO sdivisn
  38. INDEX ON product+order_no+STR(quantity,10,0) TO sproduct
  39.  
  40. SET INDEX TO svolume, sregion, sdivisn, sproduct
  41.  
  42. * Define the popup:
  43.  
  44. DEFINE POPUP reports FROM 1,20 SHADOW
  45. DEFINE BAR 1 OF reports PROMPT " Sales By \<Volume "
  46. DEFINE BAR 2 OF reports PROMPT " Sales By \<Region "
  47. DEFINE BAR 3 OF reports PROMPT " Sales By \<Division "
  48. DEFINE BAR 4 OF reports PROMPT " Sales By \<Product "
  49.  
  50. *  Note that the BARs are defined in the
  51. *  SAME ORDER as the index files were opened!
  52.  
  53. * Complete your POPUP definition with this command:
  54.  
  55.  ON SELECTION POPUP Reports DEACTIVATE POPUP
  56.  
  57. *  Now, here's the routine that calls the REPORT FORM:
  58.  
  59. DO WHILE .T.
  60.  
  61.    *  First, get the user's selection:
  62.    ACTIVATE POPUP REPORTS
  63.  
  64.    IF BAR() = 0 .OR. LASTKEY() = 27
  65.       * we didn't get a selection; ESC or right or
  66.       * left arrow was pressed
  67.       EXIT
  68.    ENDIF
  69.  
  70.    SET ORDER TO BAR()
  71.    * now we've got our grouping order
  72.  
  73.    * create a title
  74.    mtitle = "This report shows "+ALLTRIM(PROMPT())+"."
  75.  
  76.    * construct the group expression
  77.    mgroup = LEFT(KEY(BAR()), AT("+",KEY(BAR()),1)-1)
  78.  
  79.    IF LEN(mgroup) = 0
  80.        * if there wasn't an appropriate "+" in the
  81.        * index expression
  82.        mgroup = KEY(BAR())
  83.    ENDIF
  84.  
  85.    REPORT FORM salesrpt && with whatever clauses you need
  86.  
  87. ENDDO
  88. RELEASE POPUPS
  89. RELEASE ALL
  90. CLOSE ALL
  91. RETURN
  92.  
  93. **************************************************************
  94.  
  95. FUNCTION Reptgroup
  96. PARAMETERS getgroup
  97. RETURN &getgroup
  98.  
  99.  
  100.